package haven.javafx.module.base;

import javafx.util.Callback;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class SpringContext implements Callback<Class<?> ,Object> {

    public static String SPRING_XML_PATH="spring-config.xml";
    private static SpringContext ourInstance = new SpringContext(SPRING_XML_PATH);

    public static SpringContext getInstance() {
        return ourInstance;
    }
    private ApplicationContext applicationContext;
    public SpringContext(String springconfigPath) {
        this.applicationContext = new ClassPathXmlApplicationContext(springconfigPath);
    }
    @Override
    public Object call(Class<?> param) {
        return applicationContext.getBean(param);
    }
}
